<template>
  <div class="product-detail">
    <!-- 头部导航 -->
    <div class="header-nav">
      <div class="nav-tabs">
        <div class="tab">公司名称</div>
        <div class="tab">溯源管理</div>
        <div class="tab current">企业管理</div>
        <div class="tab">平台设置</div>
        <div class="tab">我的管理</div>
      </div>
      <div class="header-actions">
        <el-button type="primary" size="small">编辑</el-button>
        <el-button type="primary" size="small">导入导出设置</el-button>
        <el-button type="primary" size="small">导出模板</el-button>
      </div>
    </div>

    <div class="content-wrapper">
      <!-- 左侧产品信息 -->
      <div class="left-panel">
        <div class="product-header">
          <div class="product-images">
            <img src="/api/placeholder/150/120" alt="产品图片" class="main-image" />
            <img src="/api/placeholder/150/120" alt="产品图片" class="secondary-image" />
          </div>
          <div class="product-info">
            <h2 class="product-title">兔头（麻辣味）</h2>
            <div class="product-meta">
              <div class="meta-item">
                <span class="label">生产日期：</span>
                <span class="value">20210718</span>
              </div>
              <div class="meta-item">
                <span class="label">保质期：</span>
                <span class="value">效天</span>
              </div>
              <div class="meta-item">
                <span class="label">生产许可证号：</span>
                <span class="value">SC21320542760</span>
              </div>
              <div class="meta-item">
                <span class="label">生产企业：</span>
                <span class="value">成都蜀安食品合成工有限公司</span>
              </div>
            </div>
          </div>
        </div>

        <!-- 产品检验信息 -->
        <div class="inspection-section">
          <div class="section-tabs">
            <div class="tab-btn active" @click="activeTab = 'nutrition'">营养成分</div>
            <div class="tab-btn" @click="activeTab = 'storage'">存储条件</div>
            <div class="tab-btn" @click="activeTab = 'process'">加工工艺</div>
          </div>

          <div v-if="activeTab === 'nutrition'" class="tab-content">
            <div class="nutrition-info">
              <div class="nutrition-item">
                <span class="label">单价：</span>
                <span class="value">无</span>
              </div>
              <div class="nutrition-item">
                <span class="label">单位：</span>
                <span class="value">无</span>
              </div>
              <div class="nutrition-item">
                <span class="label">保存天数：</span>
                <span class="value">无</span>
              </div>
              <div class="nutrition-item">
                <span class="label">保存温度：</span>
                <span class="value">+1-5℃</span>
              </div>
              <div class="nutrition-item">
                <span class="label">保存湿度：</span>
                <span class="value">无</span>
              </div>
              <div class="nutrition-item">
                <span class="label">保存日期：</span>
                <span class="value">2021-06-18</span>
              </div>
            </div>
          </div>

          <div v-if="activeTab === 'storage'" class="tab-content">
            <div class="storage-info">
              <p>存储条件详细信息...</p>
            </div>
          </div>

          <div v-if="activeTab === 'process'" class="tab-content">
            <div class="process-info">
              <p>加工工艺详细信息...</p>
            </div>
          </div>
        </div>

        <!-- 企业信息 -->
        <div class="company-section">
          <h3>企业信息</h3>
          <div class="company-info">
            <div class="info-row">
              <span class="label">企业：</span>
              <span class="value">成都蜀安食品合成工有限公司</span>
            </div>
            <div class="info-row">
              <span class="label">地址：</span>
              <span class="value">四川省成都市</span>
            </div>
            <div class="info-row">
              <span class="label">保存天数：</span>
              <span class="value">90 天</span>
            </div>
            <div class="info-row">
              <span class="label">保存温度：</span>
              <span class="value">0 度</span>
            </div>
          </div>
        </div>

        <!-- 供应商信息 -->
        <div class="supplier-section">
          <h3>供应商信息</h3>
          <div class="supplier-info">
            <div class="info-row">
              <span class="label">供应商：</span>
              <span class="value">四川蜀安食品合成工有限公司</span>
            </div>
            <div class="info-row">
              <span class="label">保存天数：</span>
              <span class="value">90 天</span>
            </div>
          </div>
        </div>

        <!-- 检验信息 -->
        <div class="test-section">
          <h3>检验信息</h3>
          <div class="test-info">
            <div class="test-item">
              <span class="label">年份：</span>
              <span class="value">2021-07-18</span>
            </div>
            <div class="test-item">
              <span class="label">导入时间（点）：</span>
              <span class="value">20</span>
            </div>
            <div class="test-item">
              <span class="label">导入时间：</span>
              <span class="value">2021-06-18 18:22:01</span>
            </div>
            <div class="test-item">
              <span class="label">导出时间：</span>
              <span class="value">2021-06-18 10:50:00</span>
            </div>
          </div>
        </div>

        <!-- 企业信息详情 -->
        <div class="company-detail-section">
          <h3>企业信息</h3>
          <div class="company-detail">
            <div class="company-description">
              <p>公司简介：四川蜀安食品合成工有限公司</p>
              <p>公司地址：四川省 成都市 高新区 武侯区</p>
              <p>公司简介：企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介企业简介</p>
            </div>
          </div>
        </div>

        <!-- 企业图片 -->
        <div class="company-images-section">
          <h3>企业图片</h3>
          <div class="image-grid">
            <div class="image-item" v-for="n in 6" :key="n">
              <img src="/api/placeholder/120/80" alt="企业图片" />
              <div class="image-overlay">+</div>
            </div>
          </div>
        </div>
      </div>

      <!-- 右侧操作面板 -->
      <div class="right-panel">
        <div class="action-section">
          <h4>操作</h4>
          <div class="action-buttons">
            <el-button type="primary" @click="showCompanyInfoDialog = true">企业信息</el-button>
            <el-button type="primary" @click="showExportSettingsDialog = true">导出设置</el-button>
            <el-button type="primary" @click="showMarketingInfoDialog = true">营销信息</el-button>
          </div>
        </div>
      </div>
    </div>

    <!-- 企业信息弹窗 -->
    <el-dialog v-model="showCompanyInfoDialog" title="企业信息" width="600px">
      <el-form :model="companyForm" label-width="120px">
        <el-form-item label="公司名称：">
          <el-input v-model="companyForm.companyName" placeholder="四川蜀安食品合成工有限公司"></el-input>
        </el-form-item>
        <el-form-item label="生产许可证号：">
          <el-input v-model="companyForm.licenseNumber" placeholder="SC21320542760"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="showCompanyInfoDialog = false">取消</el-button>
        <el-button type="primary" @click="saveCompanyInfo">保存</el-button>
      </template>
    </el-dialog>

    <!-- 导出设置弹窗 -->
    <el-dialog v-model="showExportSettingsDialog" title="导出设置" width="500px">
      <el-form :model="exportSettings" label-width="100px">
        <el-form-item label="年份：">
          <el-input v-model="exportSettings.year" placeholder="2021-07-18"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="showExportSettingsDialog = false">取消</el-button>
        <el-button type="primary" @click="saveExportSettings">保存</el-button>
      </template>
    </el-dialog>

    <!-- 营销信息弹窗 -->
    <el-dialog v-model="showMarketingInfoDialog" title="营销信息" width="600px">
      <el-form :model="marketingInfo" label-width="120px">
        <el-form-item label="公司名称：">
          <el-input v-model="marketingInfo.companyName" placeholder="四川蜀安食品合成工有限公司"></el-input>
        </el-form-item>
        <el-form-item label="地址：">
          <el-select v-model="marketingInfo.province" placeholder="四川">
            <el-option label="四川" value="四川"></el-option>
          </el-select>
          <el-select v-model="marketingInfo.city" placeholder="成都市">
            <el-option label="成都市" value="成都市"></el-option>
          </el-select>
          <el-input v-model="marketingInfo.address" placeholder="详细地址"></el-input>
        </el-form-item>
        <el-form-item label="成立时间：">
          <el-date-picker v-model="marketingInfo.establishDate" type="date" placeholder="2021-06-18"></el-date-picker>
        </el-form-item>
        <el-form-item label="公司简介：">
          <el-input 
            v-model="marketingInfo.description" 
            type="textarea" 
            :rows="4"
            placeholder="请输入公司简介"
          ></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="showMarketingInfoDialog = false">取消</el-button>
        <el-button type="primary" @click="saveMarketingInfo">保存</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'

// 响应式数据
const activeTab = ref('nutrition')

// 弹窗控制
const showCompanyInfoDialog = ref(false)
const showExportSettingsDialog = ref(false)
const showMarketingInfoDialog = ref(false)

// 表单数据
const companyForm = ref({
  companyName: '',
  licenseNumber: ''
})

const exportSettings = ref({
  year: ''
})

const marketingInfo = ref({
  companyName: '',
  province: '',
  city: '',
  address: '',
  establishDate: '',
  description: ''
})

// 方法
const saveCompanyInfo = () => {
  ElMessage.success('企业信息保存成功')
  showCompanyInfoDialog.value = false
}

const saveExportSettings = () => {
  ElMessage.success('导出设置保存成功')
  showExportSettingsDialog.value = false
}

const saveMarketingInfo = () => {
  ElMessage.success('营销信息保存成功')
  showMarketingInfoDialog.value = false
}
</script>

<style scoped>
.product-detail {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
}

.header-nav {
  background: white;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e6e6e6;
}

.nav-tabs {
  display: flex;
  gap: 30px;
}

.tab {
  padding: 15px 0;
  cursor: pointer;
  position: relative;
}

.tab.current {
  background: #409eff;
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.content-wrapper {
  flex: 1;
  display: flex;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
}

.left-panel {
  flex: 1;
  background: white;
  border-radius: 8px;
  padding: 20px;
}

.product-header {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.product-images {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.main-image, .secondary-image {
  width: 150px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e6e6e6;
}

.product-info {
  flex: 1;
}

.product-title {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin: 0 0 20px 0;
}

.product-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meta-item {
  display: flex;
  align-items: center;
}

.label {
  font-weight: 600;
  color: #666;
  min-width: 120px;
}

.value {
  color: #333;
}

.inspection-section {
  margin-bottom: 30px;
}

.section-tabs {
  display: flex;
  border-bottom: 1px solid #e6e6e6;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: #666;
}

.tab-btn.active {
  color: #409eff;
  border-bottom-color: #409eff;
}

.tab-content {
  padding: 20px 0;
}

.nutrition-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.nutrition-item {
  display: flex;
  align-items: center;
}

.company-section,
.supplier-section,
.test-section,
.company-detail-section,
.company-images-section {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.company-section h3,
.supplier-section h3,
.test-section h3,
.company-detail-section h3,
.company-images-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0 0 15px 0;
}

.company-info,
.supplier-info,
.test-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-row,
.test-item {
  display: flex;
  align-items: center;
}

.company-description {
  line-height: 1.6;
  color: #666;
}

.company-description p {
  margin: 0 0 15px 0;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.image-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e6e6e6;
}

.image-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  opacity: 0;
  transition: opacity 0.3s;
}

.image-item:hover .image-overlay {
  opacity: 1;
}

.right-panel {
  width: 300px;
  background: white;
  border-radius: 8px;
  padding: 20px;
  height: fit-content;
}

.action-section h4 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 15px 0;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-buttons .el-button {
  width: 100%;
}
</style>


